<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/9/30
  Time: 9:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>form</title>
    <script src="webjars/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<form action="hello/test13" method="post">
    <input type="text" name="id">
    <input type="text" name="name">
    <input type="submit" value="提交">
</form>
</body>
<script>
    /*var xhr = new XMLHttpRequest();
    xhr.open("post","hello/test13");
    xhr.setRequestHeader("content-type","application/json");//设置请求头
    xhr.send('{"id":1,"name":"shine","gender":"true"}');//传递json串*/
    var user = {id:1,name:"shine"};
    $.ajax({
        url:'${pageContext.request.contextPath}/hello/test14',
        type:'post',
        contentType:"application/json",//声明请求参数类型为 json
        data:JSON.stringify(user),// 转换js对象成json
        success:function(ret){
            console.log(ret);
        }
    });
</script>
</html>
